package com.haizhi.crm.api.controller.sys.auth;

import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.sys.auth.model.UpdatePasswordQo;
import com.haizhi.crm.sys.auth.model.UserQo;
import com.haizhi.crm.sys.auth.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by yangyijun on 2018/5/29.
 */
@Api(description = "[系统-用户]-增删改查" )
@RestController
@RequestMapping("/user" )
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "行内用户数据导入接口" )
    @PostMapping(path = "/import" )
    public Response save(@RequestBody @Valid UserQo userQo) {
        return userService.save(userQo);
    }

    @ApiOperation(value = "个人中心-查看个人信息" )
    @GetMapping(path = "/detail" )
    public Response detail() {
        return userService.detail();
    }

    @ApiOperation(value = "个人中心-修改密码" )
    @PostMapping(path = "/updatePassword" )
    public Response updatePassword(@RequestBody @Valid UpdatePasswordQo updatePasswordQo) {
        return userService.updatePassword(updatePasswordQo);
    }
}
